home *** CD-ROM | disk | FTP | other *** search
- # Commands covered: linsert
- #
- # This file contains a collection of tests for one or more of the Tcl
- # built-in commands. Sourcing this file into Tcl runs the tests and
- # generates output for errors. No output means no errors were found.
- #
- # Copyright 1991 Regents of the University of California
- # Permission to use, copy, modify, and distribute this
- # software and its documentation for any purpose and without
- # fee is hereby granted, provided that this copyright notice
- # appears in all copies. The University of California makes no
- # representations about the suitability of this software for any
- # purpose. It is provided "as is" without express or implied
- # warranty.
- #
- # $Header: /sprite/src/lib/tcl/tests/RCS/linsert.test,v 1.1 91/08/21 13:37:24 ouster Exp $ (Berkeley)
-
- if {[string compare test [info procs test]] == 1} then {source defs}
-
- test linsert-1.1 {linsert command} {
- linsert {1 2 3 4 5} 0 a
- } {a 1 2 3 4 5}
- test linsert-1.2 {linsert command} {
- linsert {1 2 3 4 5} 1 a
- } {1 a 2 3 4 5}
- test linsert-1.3 {linsert command} {
- linsert {1 2 3 4 5} 2 a
- } {1 2 a 3 4 5}
- test linsert-1.4 {linsert command} {
- linsert {1 2 3 4 5} 3 a
- } {1 2 3 a 4 5}
- test linsert-1.5 {linsert command} {
- linsert {1 2 3 4 5} 4 a
- } {1 2 3 4 a 5}
- test linsert-1.6 {linsert command} {
- linsert {1 2 3 4 5} 5 a
- } {1 2 3 4 5 a}
- test linsert-1.7 {linsert command} {
- linsert {1 2 3 4 5} 2 one two \{three \$four
- } {1 2 one two \{three {$four} 3 4 5}
- test linsert-1.8 {linsert command} {
- linsert {\{one \$two \{three \ four \ five} 2 a b c
- } {\{one \$two a b c \{three \ four \ five}
- test linsert-1.9 {linsert command} {
- linsert {{1 2} {3 4} {5 6} {7 8}} 2 {x y} {a b}
- } {{1 2} {3 4} {x y} {a b} {5 6} {7 8}}
- test linsert-1.10 {linsert command} {
- linsert {} 2 a b c
- } {a b c}
- test linsert-1.11 {linsert command} {
- linsert {} 2 {}
- } {{}}
-
- test linsert-2.1 {linsert errors} {
- list [catch linsert msg] $msg
- } {1 {wrong # args: should be "linsert list index element ?element ...?"}}
- test linsert-2.2 {linsert errors} {
- list [catch {linsert a b} msg] $msg
- } {1 {wrong # args: should be "linsert list index element ?element ...?"}}
- test linsert-2.3 {linsert errors} {
- list [catch {linsert a 12x 2} msg] $msg
- } {1 {expected integer but got "12x"}}
- test linsert-2.4 {linsert errors} {
- list [catch {linsert \{ 12 2} msg] $msg
- } {1 {unmatched open brace in list}}
-